home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
program
/
progem.lzh
/
wind3.prf
< prev
next >
Wrap
Text File
|
1987-06-23
|
17KB
|
332 lines
.!****************************************************************************
.!
.! ANTIC PUBLISHING INC., COPYRIGHT 1985. REPRINTED BY PERMISSION.
.!
.! ** Professional GEM ** by Tim Oren
.!
.! Proff File by ST enthusiasts at
.! Case Western Reserve University
.! Cleveland, Ohio
.! uucp : decvax!cwruecmp!bammi
.! csnet: bammi@case
.! arpa : bammi%case@csnet-relay
.! compuserve: 71515,155
.!
.!****************************************************************************
.!
.!
.!****************************************************************************
.!
.! Begin Part 3
.!
.!****************************************************************************
.!
.PART III THE DIALOG HANDLER
.SH A MEANINGFUL DIALOG
This issue of ST PRO GEM begins an exploration of ST GEM's dialog handler. I
will discuss basic system calls for presenting the dialog, and then continue
with techniques for initializing and reading on/off button and "radio" button
objects. We will also take some short side-trips into the operation
of the GEM Resource Construction Set to assist you in building these dialogs.
.PP
There are a number of short C routines which accompany this column. These are
stored as file GEMCL3.XMO in DL 5 on SIG*ATARI. Before reading this column, you
should visit SIG*ATARI (go pcs-132) and download this file.
.PP
.SH DEFINING TERMS
A dialog box is an "interactive form" in which the user may enter text and
indicate selections by pointing with the mouse. Dialogs in GEM are
"modal", that is, when a dialog is activated other screen functions
such as menus and window controls are suspended until the dialog is completed.
.PP
In most cases, the visual structure of a GEM dialog is specified within your
application's resource file. The GEM Resource Construction Set (RCS)
is used to build a picture of the dialog.
.PP
When the RCS writes out a resource, it converts that picture into a tree of
GEM drawing objects and stores this data structure within the resource. Before
your application can display the dialog, it must load this resource file and
find the address of the tree which defines the dialog.
.PP
To load a resource, the AES checks its size and allocates memory for the
load. It then reads in the resource, adjusting internal pointers to
reflect the load address. Finally, the object sizes stored in the
resource are converted from characters to pixels using the system font size.
.PP
A note for those with Macintosh experience: Although Mac and GEM resources
share a name, there are fundamental differences which can be misleading. A Mac
resource is a fork within a file; a GEM resource is a TOS file by itself. Mac
resources may be paged in and out of memory; GEM resources are monolithic. GEM
resources are internally tree structured; Mac resources are not. Finally, Mac
resources include font information, while ST GEM does this with font loading at
the VDI level.
.PP
The resource load is done with the GEM AES call:
.FB rsrc_load()
ok = rsrc_load(ADDR("MYAPP.RSC"));
.FE
"MYAPP" should be replaced with the name of your program. Resources
conventionally have the same primary name as their application, with the RSC
extent name instead of PRG. The ok flag returned by rsrc_load will be FALSE is
anything went wrong during the load.
.PP
The most common causes of failure are the resource not being in the
application's subdirectory, or lack of sufficient memory for GEM to allocate
space for the resource. If this happens, you must terminate the program
immediately.
.PP
Once you have loaded the resource, you find the address of a dialog's object
tree with:
.FB rsrc_gaddr()
rsrc_gaddr(R_TREE, MYDIALOG, &tree);
.FE
Tree is a 32-bit variable which will receive the address of the root
node of the tree.
.PP
The mnemonic MYDIALOG should be replaced with the name you gave your dialog
when defining it in the RCS. At the same time that it writes the resource, RCS
generates a corresponding .H file containing tree and object names.
In order to use these mnemonics within your program, you must include
the name file in your compile: #include "MYAPP.H"
.SH BUG ALERT!
When using the DRI/Alcyon C compiler, .H files must be in the compiler's home
directory or they will not be found. This is especially annoying using a two
floppy drive ST development system. The only way around this is to explicitly
reference an alternate disk in the #include, for instance: "B:MYAPP.H".
[Ed. Note: Use the -i flag with the C pre-processor to name the include
directories].
.PP
Now that the address of the dialog tree has been found, you are ready to
display it. The standard (and minimal) sequence for doing so is given in
routine hndl_dial() in the download. We will now walk through each
step in this procedure.
.PP
The form_center call establishes the location of the dialog on the screen.
Dialog trees generated by the RCS have an undefined origin (upper-left corner).
.PP
Form_center computes the upper-left location necessary to center the dialog
on the screen, and inserts it into the OB_X and OB_Y fields of the ROOT object
of the tree. It also computes the screen rectangle which the dialog
will occupy on screen and writes its pixel coordinates into variables
xdial, ydial, wdial, and hdial.
.PP
There is one peculiarity of form_center which occasionally causes trouble.
Normally the rectangle returned in xdial, etc., is exactly the same size as the
basic dialog box.
.PP
However, when the OUTLINED enhancement has been specified for the box,
form_center adds a three pixel margin to the rectangle returned. This
causes the screen area under the outline to be correctly redrawn later
(see below). Note that OUTLINED is part of the standard dialog box in
the RCS. Other enhancements, such as SHADOWED or "outside" borders
are NOT handled in this fashion, and you must compensate for them in
your code.
.PP
The next part of the sequence is a form_dial call with a zero parameter.
This reserves the screen for the dialog action about to occur. Note that the C
binding given for form_dial in the DRI documents is in error: there are nine
parameters, not five. The first set of xywh arguments is actually used with
form_dial calls 1 and 2 only, but place holders must be supplied in all cases.
.PP
The succeeding form_dial call (parameter one) animates a "zoom box" on the
screen which moves and grows from the first screen rectangle given to
the second rectangle, where the dialog will be displayed.
.PP
The use of this call is entirely optional. In choosing whether to use it or
not, you should consider whether the origin of the "zoom" is relevant to the
operation. For instance, a zoom from the menu bar is relatively meaningless,
while a zoom from an object about to be edited in the dialog provides visual
feedback to the user, showing whether the correct object was chosen.
.PP
If the origin is not relevant, then the zoom is just a time-waster. If you
decide to include these effects, consider a "preferences" option in your app
which will allow the experienced and jaded user to turn them off in the
interests of speed.
.PP
The objc_draw call actually displays the dialog on the screen. Note that the
address of the tree, the beginning drawing object, and the drawing depth are
passed as arguments, as well as the rectangle allotted for the dialog.
.PP
In general, dialogs (and parts of dialogs) are ALWAYS drawn beginning at the
ROOT (object zero). When you want to draw only a portion of the
dialog, adjust the clipping rectangle, but not the object number.
This ensures that the background of the dialog is always drawn correctly.
.PP
The objc_xywh() utility in the download can be used to find the clipping
rectangle for any object within a dialog, though you may have to allow an extra
margin is you have used shadows, outlines, or outside borders with the object.
.PP
Calling form_do transfers control to the AES, which animates the dialog for
user interaction. The address of the dialog tree is passed as a
parameter. The second paramter is the number of the editable object
at which the text cursor will first be positioned. If you have no text
fields, pass a zero. Note that again the DRI documents are in error:
pas